<?php
include("CrawlerURL4399.php");
include("ParseContent4399.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$sitename?> | <?=$sitenameadd?></title>
<meta name="keywords" content="<?=$sitename?>" />
<meta name="description" content="<?=$sitedescription?>" />
<base href="<?=$baseurl?>">
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
ignore_user_abort();           // 即使Client断开(如关掉浏览器)，PHP脚本也可以继续执行.
set_time_limit(0);             // 执行时间为无限制，php默认的执行时间是30秒，通过set_time_limit(0)可以让程序无限制的执行下去

$beginurls = array (
    array("动作","http://www.4399.com/flash_fl/2_1.htm"),
    array("动作","http://www.4399.com/flash_fl/more_2_2.htm"),
    array("动作","http://www.4399.com/flash_fl/more_2_3.htm"),
    array("体育","http://www.4399.com/flash_fl/3_1.htm"),
    array("体育","http://www.4399.com/flash_fl/more_3_2.htm"),
    array("体育","http://www.4399.com/flash_fl/more_3_3.htm"),
    array("体育","http://www.4399.com/flash_fl/more_3_4.htm"),
    array("体育","http://www.4399.com/flash_fl/more_3_5.htm"),
    array("体育","http://www.4399.com/flash_fl/more_3_6.htm"),
    array("体育","http://www.4399.com/flash_fl/more_3_7.htm"),
    array("体育","http://www.4399.com/flash_fl/more_3_8.htm"),
    array("体育","http://www.4399.com/flash_fl/more_3_9.htm"),
    array("益智","http://www.4399.com/flash_fl/5_1.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_2.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_3.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_4.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_5.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_6.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_7.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_8.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_9.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_10.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_11.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_12.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_13.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_14.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_15.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_16.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_17.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_18.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_19.htm"),
    array("益智","http://www.4399.com/flash_fl/more_5_20.htm"),
    array("射击","http://www.4399.com/flash_fl/4_1.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_2.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_3.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_4.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_5.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_6.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_7.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_8.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_9.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_10.htm"),
    array("射击","http://www.4399.com/flash_fl/more_4_11.htm"),
    array("搞笑","http://www.4399.com/flash_fl/1_1.htm"),
    array("冒险","http://www.4399.com/flash_fl/6_1.htm"),
    array("冒险","http://www.4399.com/flash_fl/more_6_2.htm"),
    array("冒险","http://www.4399.com/flash_fl/more_6_3.htm"),
    array("冒险","http://www.4399.com/flash_fl/more_6_4.htm"),
    array("冒险","http://www.4399.com/flash_fl/more_6_5.htm"),
    array("冒险","http://www.4399.com/flash_fl/more_6_6.htm"),
    array("棋牌","http://www.4399.com/flash_fl/7_1.htm"),
    array("策略","http://www.4399.com/flash_fl/8_1.htm"),
    array("敏捷","http://www.4399.com/flash_fl/11_1.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_2.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_3.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_4.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_5.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_6.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_7.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_8.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_9.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_10.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_11.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_12.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_13.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_14.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_15.htm"),
    array("敏捷","http://www.4399.com/flash_fl/more_11_16.htm"),
    array("综合","http://www.4399.com/flash_fl/9_1.htm"),
    array("休闲","http://www.4399.com/flash_fl/12_1.htm"),
    array("休闲","http://www.4399.com/flash_fl/more_12_2.htm"),
    array("休闲","http://www.4399.com/flash_fl/more_12_3.htm"),
    array("休闲","http://www.4399.com/flash_fl/more_12_4.htm"),
    array("休闲","http://www.4399.com/flash_fl/more_12_5.htm"),
    array("休闲","http://www.4399.com/flash_fl/more_12_6.htm"),
    array("休闲","http://www.4399.com/flash_fl/more_12_7.htm"),
    array("休闲","http://www.4399.com/flash_fl/more_12_8.htm"),
    array("休闲","http://www.4399.com/flash_fl/more_12_9.htm"),
    array("休闲","http://www.4399.com/flash_fl/more_12_10.htm"),
    array("装扮","http://www.4399.com/flash_fl/16_1.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_2.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_3.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_4.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_5.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_6.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_7.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_8.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_9.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_10.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_11.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_12.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_13.htm"),
    array("装扮","http://www.4399.com/flash_fl/more_16_14.htm"),
    array("儿童","http://www.4399.com/flash_fl/13_1.htm"),
    array("儿童","http://www.4399.com/flash_fl/more_13_2.htm"),
    array("儿童","http://www.4399.com/flash_fl/more_13_3.htm"),
    array("儿童","http://www.4399.com/flash_fl/more_13_4.htm"),
    array("儿童","http://www.4399.com/flash_fl/more_13_5.htm"),
    array("经营","http://www.4399.com/flash_fl/49_1.htm"),
    array("经营","http://www.4399.com/flash_fl/more_49_2.htm")
);

foreach ($beginurls as $url){
	$cname = $url[0];
	$category = $url[1];
	$urlpattern = "<p><a href='(.*?)'>";

	$in = new InsertDate();
	$cid = $in->insertCategory($cname);
	
	
	//采集出类别页面的全部游戏地址
	$c = new CrawerURL4399();
	$urls = $c->parseURLS("$category", $urlpattern);
	
	$p = new ParseContent4399();
	
	//匹配每个游戏属性的正则表达式数字
	$regs = array("name" =>"游戏名:<\/strong>(.*?)<\/li>", 
				 "type" =>"分类:<\/strong>(.*?)<\/li>",
	             "date" =>"日期:<\/strong>(.*?)<\/li>",
	             "size" =>"大小:<\/strong>(.*?)<\/li>",
	             "introduce" =>"<!--键盘操作指南-->([\s\S]*?)<center",
	             "pfurl" =>"<div class=\"lim\"><a href='(.*?)' target=\"_self\">(.*?)src='(.*?)'(.*?)<\/a><\/div>");
	
	//采集出上面一个类别下的全部游戏url的详细信息
	$p->parseAllContent($urls, $regs,$cid);
}
?>
</body>
</html>
